package com.sd.sdk.core.utils;

/**
 *
 * @author xy
 */
public class ApiHexUtil {
    private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
    public static String encode(byte[] data) {
        final int len = data.length;
        final char[] out = new char[len << 1];
        for (int i = 0, j = 0; i < len; i++) {
            out[j++] = HEX_CHAR[(0xF0 & data[i]) >>> 4];
            out[j++] = HEX_CHAR[0x0F & data[i]];
        }
        return new String(out);
    }
}
